//
//  HTClassCustomButton.swift
//  QuitSmokingApp
//
//  Created by z on 2024/3/17.
//

import UIKit

class HTClassCustomButton: UIView {
    
    lazy var var_bgImg: UIImageView = {
       let var_bg = UIImageView()
        var_bg.image = UIImage(named: "icon_theme_btn_bg")
        var_bg.isHidden = true
        return var_bg
    }()
    
    lazy var var_titleLab: HTClassCustomLabel = {
        let var_title = HTClassCustomLabel()
        var_title.isUserInteractionEnabled = true
        var_title.text = "Button"
        var_title.textAlignment = .center
        var_title.font = .systemFont(ofSize: 18, weight: .bold)
        var_title.textColor = .white
        var_title.var_strokeColor = .black
        var_title.var_strokeWidth = 2
        var_title.layer.masksToBounds = true
        var_title.layer.cornerRadius = 8.auto()
        return var_title
    }()
    
    lazy var var_btn = UIButton()
    
    var isSelected: Bool = false {
        didSet {
            if isSelected == true {
                var_bgImg.isHidden = false
                var_titleLab.font = .systemFont(ofSize: 18, weight: .bold)
            }else{
                var_bgImg.isHidden = true
                var_titleLab.font = .systemFont(ofSize: 16, weight: .medium)
            }
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        ht_initWithUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func ht_initWithUI(){
        self.addSubview(var_bgImg)
        var_bgImg.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        self.addSubview(var_titleLab)
        var_titleLab.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        self.addSubview(var_btn)
        var_btn.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
    }
    
    
}
